package com.atguigu.wordcount.multiplejob;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @ClassName Ex2Reducer
 * @DeScription Ex2Reducer
 * @Author 剧情再美终是戏
 * @Date 2019/11/20 14:54
 * @Version 1.0
 **/

// 输入：atguigu  a.txt 3 atguigu  b.txt 3
// 输出： atguigu a.txt 3  b.txt 3
public class Ex2Reducer extends Reducer<Text, Text, Text, Text> {

    private Text out_value = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {

        StringBuffer sb = new StringBuffer();
        for (Text value : values) {
            sb.append(value + "\t");
        }
        out_value.set(sb.toString());
        context.write(key, out_value);
    }
}
